<template>
    <div class="treaty">
        <!-- 新增来源弹窗 -->
        <el-dialog :title="title" :visible.sync="dialogVisible" class="cmschina-dialog" :close-on-click-modal="false" destroy-on-close>
            <div class="treaty-title">条款信息</div>
            <hr />
            <!-- 条款迁移路径设置 -->
            <template v-if="['单个复制', '多个复制', '单个复制制度解读类'].includes(sourceSettteingType)">
                <div class="card-title">条款迁移路径设置</div>
                <div class="card-content">
                    <el-form :inline="true" :model="removal" label-width="130px">
                        <el-row class="form-row">
                            <el-col :span="8">
                                <el-form-item label="迁移来源类型:">
                                    <el-select v-model="removal.directoryCode" placeholder="请选择" size="mini" @change="changeSourceType">
                                        <el-option
                                            :label="item.indexName"
                                            :value="item.indexDirectoryCode"
                                            v-for="item in indexSourceCodeSelect"
                                            :key="item.indexDirectoryCode"
                                            >{{ item.indexName }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="迁移来源名称:">
                                    <el-select v-model="removal.indexSourceName" placeholder="请选择" size="mini" @change="changeMovedIndexSource">
                                        <el-option
                                            :label="item.articleName"
                                            :value="item.articleCode"
                                            v-for="item in indexSourceCodeSelect1"
                                            :key="item.articleCode"
                                            >{{ item.articleName }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="迁移来源版本号:">
                                    <el-select v-model="removal.articleDeatilsCode" filterable clearable placeholder="请选择" size="mini">
                                        <el-option
                                            :label="item.versionNumber"
                                            :value="item.articleDeatilsCode"
                                            v-for="item in moveIndexArticleCodeList"
                                            :key="item.articleDeatilsCode"
                                            >{{ item.versionNumber }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </template>

            <!-- 条款基础信息-新增、修改、查看 -->
            <template v-if="!['多个复制'].includes(sourceSettteingType)">
                <div class="card-title">条款基础信息</div>
                <div class="card-content">
                    <el-form :inline="true" :model="indexClause" label-width="105px">
                        <el-row class="form-row" v-if="!['单个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)">
                            <el-col :span="7">
                                <el-form-item label="来源类型:" v-if="['监管类新增', '监管类修改', '监管类查看'].includes(sourceSettteingType)">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select
                                        v-model="indexClause.directoryCode"
                                        placeholder="请选择"
                                        size="mini"
                                        :disabled="['监管类新增', '监管类修改', '监管类查看'].includes(sourceSettteingType)"
                                    >
                                        <el-option
                                            :label="item.indexName"
                                            :value="item.indexDirectoryCode"
                                            v-for="item in indexSourceCodeSelect"
                                            :key="item.indexDirectoryCode"
                                            >{{ item.indexDirectoryCode }} {{ item.indexName }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="产品类型:" v-else-if="['合同类新增', '合同类修改', '合同类查看'].includes(sourceSettteingType)">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select
                                        v-model="indexClause.directoryCode"
                                        placeholder="请选择"
                                        size="mini"
                                        :disabled="['合同类新增', '合同类查看', '合同类修改'].includes(sourceSettteingType)"
                                    >
                                        <el-option
                                            :label="item.indexName"
                                            :value="item.indexDirectoryCode"
                                            v-for="item in indexSourceCodeSelect"
                                            :key="item.indexDirectoryCode"
                                            >{{ item.indexDirectoryCode }} {{ item.indexName }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                                <el-form-item
                                    label="制度类型:"
                                    v-else-if="
                                        ['制度解读类新增', '制度解读类修改', '制度解读类查看', '单个复制制度解读类'].includes(sourceSettteingType)
                                    "
                                >
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select v-model="indexClause.directoryCode" placeholder="请选择" size="mini" disabled>
                                        <el-option
                                            :label="item.indexName"
                                            :value="item.indexDirectoryCode"
                                            v-for="item in indexSourceCodeSelect"
                                            :key="item.indexDirectoryCode"
                                            >{{ item.indexDirectoryCode }} {{ item.indexName }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="7">
                                <el-form-item label="来源名称:" v-if="['监管类新增', '监管类修改', '监管类查看'].includes(sourceSettteingType)">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <!-- -->
                                    <el-select
                                        v-model="indexClause.articleCode"
                                        placeholder="请选择"
                                        size="mini"
                                        :disabled="['监管类查看', '监管类新增', '监管类修改'].includes(sourceSettteingType)"
                                    >
                                        <el-option
                                            :label="item.articleName"
                                            :value="item.articleCode"
                                            v-for="item in indexSourceCodeSelect1"
                                            :key="item.articleCode"
                                            >{{ item.articleCode }} {{ item.articleName }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="产品信息:" v-else-if="['合同类新增', '合同类修改', '合同类查看'].includes(sourceSettteingType)">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select
                                        v-model="indexClause.productCode"
                                        placeholder="请选择"
                                        size="mini"
                                        :disabled="['合同类新增', '合同类修改', '合同类查看'].includes(sourceSettteingType)"
                                    >
                                        <el-option
                                            :label="item.indexName"
                                            :value="item.productCode"
                                            v-for="item in itemProduct"
                                            :key="item.productCode"
                                            >{{ item.indexName }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                                <el-form-item
                                    label="制度名称:"
                                    v-else-if="
                                        ['制度解读类新增', '制度解读类修改', '制度解读类查看', '单个复制制度解读类'].includes(sourceSettteingType)
                                    "
                                >
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select v-model="indexClause.articleCode" placeholder="请选择" size="mini" disabled>
                                        <el-option
                                            :label="item.articleName"
                                            :value="item.articleCode"
                                            v-for="item in indexSourceCodeSelect1"
                                            :key="item.articleCode"
                                            >{{ item.articleCode }} {{ item.articleName }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="7">
                                <el-form-item
                                    label="版本号:"
                                    v-if="
                                        [
                                            '监管类新增',
                                            '监管类修改',
                                            '监管类查看',
                                            '制度解读类新增',
                                            '制度解读类修改',
                                            '制度解读类查看',
                                            '单个复制制度解读类',
                                        ].includes(sourceSettteingType)
                                    "
                                >
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select v-model="indexClause.versionNumber" placeholder="请选择" size="mini" :disabled="disabledAll">
                                        <el-option
                                            :label="item.versionNumber"
                                            :value="item.articleDeatilsCode"
                                            v-for="item in VersionNums"
                                            :key="item.articleDeatilsCode"
                                            >{{ item.versionNumber }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="合同名称:" v-else-if="['合同类新增', '合同类修改', '合同类查看'].includes(sourceSettteingType)">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select v-model="indexClause.versionNumber" placeholder="请选择" size="mini" :disabled="disabledAll">
                                        <el-option
                                            :label="item.versionNumber"
                                            :value="item.articleDeatilsCode"
                                            v-for="item in VersionNums"
                                            :key="item.articleDeatilsCode"
                                            >{{ item.versionNumber }}</el-option
                                        >
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="3">
                                <el-form-item label="">
                                    <el-radio-group v-model="indexClause.clauseStatus" :disabled="disabledAll">
                                        <el-radio label="1">启用</el-radio>
                                        <el-radio label="0">停用</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col :span="7">
                                <el-form-item label="条款类型:" v-if="['合同类新增', '合同类修改', '合同类查看'].includes(sourceSettteingType)">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select v-model="indexClause.clauseType" placeholder="请选择" size="mini" :disabled="disabledAll">
                                        <el-option label="投资范围" value="0" key="0"></el-option>
                                        <el-option label="投资限制" value="1" key="1"></el-option>
                                        <!-- <el-option label="关联交易" value="2" key="2"></el-option> -->
                                        <el-option label="其它" value="3" key="3"></el-option>
                                        <el-option label="监管条款" value="4"></el-option>
                                        <el-option label="预警止损线" value="5"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="7">
                                <el-form-item
                                    label="条款号:"
                                    v-if="
                                        [
                                            '监管类新增',
                                            '监管类修改',
                                            '监管类查看',
                                            '单个复制',
                                            '合同类新增',
                                            '合同类修改',
                                            '合同类查看',
                                            '制度解读类新增',
                                            '制度解读类修改',
                                            '制度解读类查看',
                                            '单个复制制度解读类',
                                        ].includes(sourceSettteingType)
                                    "
                                >
                                    <!-- <span style="position: absolute; left: -10px; color: red">*</span> -->
                                    <el-input v-model="indexClause.clauseNo" size="mini" style="width: 105%" :disabled="disabledAll"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="3" v-if="['单个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)">
                                <el-form-item label="">
                                    <el-radio-group v-model="indexClause.clauseStatus" :disabled="disabledAll">
                                        <el-radio label="1">启用</el-radio>
                                        <el-radio label="0">停用</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row
                            class="form-row"
                            v-if="!['制度解读类新增', '制度解读类修改', '制度解读类查看', '单个复制制度解读类'].includes(sourceSettteingType)"
                        >
                            <el-col :span="24">
                                <el-form-item label="条款原文:" class="textarea-width">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.clauseText"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row
                            class="form-row"
                            v-if="!['制度解读类新增', '制度解读类修改', '制度解读类查看', '单个复制制度解读类'].includes(sourceSettteingType)"
                        >
                            <el-col :span="24">
                                <el-form-item label="执行标准:" class="textarea-width">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.executiveStandArd"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        :disabled="disabledAll"
                                    ></el-input>
                                    <div style="display: flex">
                                        <div style="font-size: 12px">附件:</div>
                                        <el-upload
                                            :multiple="true"
                                            :action="actionUrl"
                                            :headers="headerObj"
                                            :with-credentials="true"
                                            list-type="text"
                                            :show-file-list="false"
                                            :disabled="disabledAll"
                                            :on-success="
                                                (res, file, fileList) => {
                                                    return uploadFileSuccess(res, file, fileList, '执行标准');
                                                }
                                            "
                                            :on-error="
                                                (res, file, fileList) => {
                                                    return uploadFileError(res, file, fileList, '执行标准');
                                                }
                                            "
                                        >
                                            <el-button size="small" icon="el-icon-plus" style="border: none" :disabled="disabledAll"
                                                >添加文件</el-button
                                            >
                                        </el-upload>
                                    </div>
                                    <UploadFileShow
                                        :fileList="fileList1"
                                        @emitDownLoadFile="downLoadFileBtn"
                                        @emitConfirmDelFile="confirmDelFile1"
                                    ></UploadFileShow>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row
                            class="form-row"
                            v-if="!['制度解读类新增', '制度解读类修改', '制度解读类查看', '单个复制制度解读类'].includes(sourceSettteingType)"
                        >
                            <el-col :span="24">
                                <el-form-item label="托管行意见:" class="textarea-width">
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.depositOpinions"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        :disabled="disabledAll"
                                    ></el-input>
                                    <div style="display: flex">
                                        <div style="font-size: 12px">附件:</div>
                                        <el-upload
                                            :multiple="false"
                                            :action="actionUrl"
                                            :headers="headerObj"
                                            :with-credentials="true"
                                            list-type="text"
                                            :show-file-list="false"
                                            :disabled="disabledAll"
                                            :on-success="
                                                (res, file, fileList) => {
                                                    return uploadFileSuccess(res, file, fileList, '托管行意见');
                                                }
                                            "
                                            :on-error="
                                                (res, file, fileList) => {
                                                    return uploadFileError(res, file, fileList, '托管行意见');
                                                }
                                            "
                                        >
                                            <el-button size="small" icon="el-icon-plus" style="border: none" :disabled="disabledAll"
                                                >添加文件</el-button
                                            >
                                        </el-upload>
                                    </div>
                                    <UploadFileShow
                                        :fileList="fileList2"
                                        @emitDownLoadFile="downLoadFileBtn"
                                        @emitConfirmDelFile="confirmDelFile2"
                                    ></UploadFileShow>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row
                            class="form-row"
                            v-if="!['制度解读类新增', '制度解读类修改', '制度解读类查看', '单个复制制度解读类'].includes(sourceSettteingType)"
                        >
                            <el-col :span="24">
                                <el-form-item label="行业调研:" class="textarea-width">
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.industryResearch"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        :disabled="disabledAll"
                                    ></el-input>
                                    <div style="display: flex">
                                        <div style="font-size: 12px">附件:</div>
                                        <el-upload
                                            multiple
                                            class="upload-demo"
                                            :action="actionUrl"
                                            :headers="headerObj"
                                            :with-credentials="true"
                                            list-type="text"
                                            :show-file-list="false"
                                            :disabled="disabledAll"
                                            :on-success="
                                                (res, file, fileList) => {
                                                    return uploadFileSuccess(res, file, fileList, '行业调研');
                                                }
                                            "
                                            :on-error="
                                                (res, file, fileList) => {
                                                    return uploadFileError(res, file, fileList, '行业调研');
                                                }
                                            "
                                        >
                                            <el-button size="small" icon="el-icon-plus" style="border: none" :disabled="disabledAll"
                                                >添加文件</el-button
                                            >
                                        </el-upload>
                                    </div>
                                    <UploadFileShow
                                        :fileList="fileList3"
                                        @emitDownLoadFile="downLoadFileBtn"
                                        @emitConfirmDelFile="confirmDelFile3"
                                    ></UploadFileShow>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row
                            class="form-row"
                            v-if="['制度解读类新增', '制度解读类修改', '制度解读类查看', '单个复制制度解读类'].includes(sourceSettteingType)"
                        >
                            <el-col :span="24">
                                <el-form-item label="制度条款:" class="textarea-width">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.institutionalProvisions"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row
                            class="form-row"
                            v-if="['制度解读类新增', '制度解读类修改', '制度解读类查看', '单个复制制度解读类'].includes(sourceSettteingType)"
                        >
                            <el-col :span="24">
                                <el-form-item label="条款解读:" class="textarea-width">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.executiveStandArd"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        :disabled="disabledAll"
                                    ></el-input>
                                    <div style="display: flex">
                                        <div style="font-size: 12px">附件:</div>
                                        <el-upload
                                            :multiple="true"
                                            :action="actionUrl"
                                            :headers="headerObj"
                                            :with-credentials="true"
                                            list-type="text"
                                            :show-file-list="false"
                                            :disabled="disabledAll"
                                            :on-success="
                                                (res, file, fileList) => {
                                                    return uploadFileSuccess(res, file, fileList, '执行标准');
                                                }
                                            "
                                            :on-error="
                                                (res, file, fileList) => {
                                                    return uploadFileError(res, file, fileList, '执行标准');
                                                }
                                            "
                                        >
                                            <el-button size="small" icon="el-icon-plus" style="border: none" :disabled="disabledAll"
                                                >添加文件</el-button
                                            >
                                        </el-upload>
                                    </div>
                                    <UploadFileShow
                                        :fileList="fileList1"
                                        @emitDownLoadFile="downLoadFileBtn"
                                        @emitConfirmDelFile="confirmDelFile1"
                                    ></UploadFileShow>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row fdg-row" v-if="!['单个复制', '单个复制制度解读类'].includes(sourceSettteingType)">
                            <el-col :span="24">
                                <el-form-item label="注意事项:" class="textarea-width">
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.announcements"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        :disabled="disabledAll"
                                    ></el-input>
                                    <div style="display: flex">
                                        <div style="font-size: 12px">附件:</div>
                                        <el-upload
                                            multiple
                                            class="upload-demo"
                                            :action="actionUrl"
                                            :headers="headerObj"
                                            :with-credentials="true"
                                            list-type="text"
                                            :show-file-list="false"
                                            :disabled="disabledAll"
                                            :on-success="
                                                (res, file, fileList) => {
                                                    return uploadFileSuccess(res, file, fileList, '注意事项');
                                                }
                                            "
                                            :on-error="
                                                (res, file, fileList) => {
                                                    return uploadFileError(res, file, fileList, '注意事项');
                                                }
                                            "
                                        >
                                            <el-button size="small" icon="el-icon-plus" style="border: none" :disabled="disabledAll"
                                                >添加文件</el-button
                                            >
                                        </el-upload>
                                    </div>
                                    <UploadFileShow
                                        :fileList="fileList4"
                                        @emitDownLoadFile="downLoadFileBtn"
                                        @emitConfirmDelFile="confirmDelFile4"
                                    ></UploadFileShow>
                                </el-form-item>
                            </el-col>
                            <el-button class="fdg-btn" type="primary" size="mini" @click="goToFundGroup">维护账户组</el-button>
                        </el-row>
                    </el-form>
                </div>
            </template>

            <!-- 超限设置 -->
            <template v-if="['合同类新增', '合同类修改', '合同类查看'].includes(sourceSettteingType)">
                <div class="card-title">超限设置</div>
                <div class="card-content">
                    <el-form :inline="true" :model="indexClause" label-width="130px">
                        <el-row class="form-row">
                            <el-col :span="8">
                                <el-form-item label="是否可被动超限:">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select
                                        v-model="indexClause.passiveTransfinite"
                                        placeholder="请选择"
                                        size="mini"
                                        :disabled="disabledAll"
                                        @change="changePassiveTransfinite"
                                    >
                                        <el-option label="是" value="1"></el-option>
                                        <el-option label="否" value="0"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" v-if="indexClause.passiveTransfinite == '1'">
                                <el-form-item label="超限调整时间:">
                                    <span v-if="indexClause.passiveTransfinite == '1'" style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select
                                        v-model="indexClause.transfiniteType"
                                        placeholder="请选择"
                                        size="mini"
                                        :disabled="indexClause.passiveTransfinite == '0' || disabledAll"
                                        clearable
                                    >
                                        <el-option label="交易所交易日" value="2"></el-option>
                                        <el-option label="银行间交易日" value="3"></el-option>
                                        <el-option label="自然日" value="1"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="2" v-if="indexClause.passiveTransfinite == '1'">
                                <el-form-item label="">
                                    <el-input
                                        :disabled="indexClause.passiveTransfinite == '0' || disabledAll"
                                        v-model="indexClause.transfiniteTime"
                                        size="mini"
                                        maxlength="3"
                                        @blur="blurDay($event)"
                                        @focus="blurDay($event)"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="1" v-if="indexClause.passiveTransfinite == '1'">
                                <div style="margin-top: 8px">天</div>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </template>

            <!-- 条款适用产品范围 -->
            <template
                v-if="
                    [
                        '监管类新增',
                        '监管类修改',
                        '监管类查看',
                        '单个复制',
                        '制度解读类新增',
                        '制度解读类修改',
                        '制度解读类查看',
                        '单个复制制度解读类',
                    ].includes(sourceSettteingType)
                "
            >
                <div class="card-title">条款适用产品范围</div>
                <div class="card-content">
                    <el-form :inline="true" :model="indexClause" label-width="130px">
                        <el-row class="form-row">
                            <el-col :span="8">
                                <el-form-item label="是否可被动超限:">
                                    <span style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select
                                        v-model="indexClause.passiveTransfinite"
                                        placeholder="请选择"
                                        size="mini"
                                        :disabled="disabledAll"
                                        @change="changePassiveTransfinite"
                                    >
                                        <el-option label="是" value="1"></el-option>
                                        <el-option label="否" value="0"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" v-if="indexClause.passiveTransfinite == '1'">
                                <el-form-item label="超限调整时间:">
                                    <span v-if="indexClause.passiveTransfinite == '1'" style="position: absolute; left: -10px; color: red">*</span>
                                    <el-select
                                        v-model="indexClause.transfiniteType"
                                        placeholder="请选择"
                                        size="mini"
                                        :disabled="indexClause.passiveTransfinite == '0' || disabledAll"
                                        clearable
                                    >
                                        <el-option label="交易所交易日" value="2"></el-option>
                                        <el-option label="银行间交易日" value="3"></el-option>
                                        <el-option label="自然日" value="1"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="2" v-if="indexClause.passiveTransfinite == '1'">
                                <el-form-item label="">
                                    <el-input
                                        :disabled="indexClause.passiveTransfinite == '0' || disabledAll"
                                        v-model="indexClause.transfiniteTime"
                                        size="mini"
                                        maxlength="3"
                                        @blur="blurDay($event)"
                                        @focus="blurDay($event)"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="1" v-if="indexClause.passiveTransfinite == '1'">
                                <div style="margin-top: 8px">天</div>
                            </el-col>
                        </el-row>
                        <el-row class="form-row" style="padding-left: 20px">
                            <el-col :span="2.5">
                                <el-form-item label="">
                                    <el-checkbox
                                        v-model="pcProductType"
                                        style="margin-left: 20px"
                                        :disabled="disabledAll"
                                        @change="changePcProductType"
                                        >公募产品</el-checkbox
                                    >
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="">
                                    <el-select
                                        v-model="indexClause.pcProductType"
                                        @change="changePcProductTypeSelect"
                                        placeholder="请选择"
                                        size="mini"
                                        multiple
                                        collapse-tags
                                        clearable
                                        :disabled="disabledAll"
                                    >
                                        <el-option label="股票基金" value="1"></el-option>
                                        <el-option label="债券基金" value="2"></el-option>
                                        <el-option label="混合基金" value="3"></el-option>
                                        <el-option label="货币基金" value="4"></el-option>
                                    </el-select>
                                    <el-select
                                        v-model="indexClause.pcProductType2"
                                        @change="changePcProductTypeSelect2"
                                        placeholder="请选择"
                                        size="mini"
                                        multiple
                                        collapse-tags
                                        clearable
                                        :disabled="disabledAll"
                                    >
                                        <el-option label="指数基金" value="5"></el-option>
                                        <el-option label="现金管理" value="6"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="2.5" style="padding-left: 35px">
                                <el-form-item label="">
                                    <el-checkbox
                                        v-model="ptProductType1"
                                        style="margin-left: 20px"
                                        :disabled="disabledAll"
                                        @change="changePtProductType1"
                                        >私募产品</el-checkbox
                                    >
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="">
                                    <el-select
                                        v-model="indexClause.ptProductType1"
                                        @change="changeptProductTypeSelect"
                                        placeholder="请选择"
                                        multiple
                                        collapse-tags
                                        size="mini"
                                        clearable
                                        :disabled="disabledAll"
                                    >
                                        <el-option label="集合" value="A2"></el-option>
                                        <el-option label="单一" value="B1"></el-option>
                                    </el-select>
                                    <el-select
                                        v-model="indexClause.ptProductType2"
                                        @change="changeptptProductType2Select"
                                        placeholder="请选择"
                                        multiple
                                        collapse-tags
                                        size="mini"
                                        clearable
                                        :disabled="disabledAll"
                                    >
                                        <el-option label="固收类" value="A"></el-option>
                                        <el-option label="权益类" value="B"></el-option>
                                        <el-option label="混合类" value="C"></el-option>
                                        <el-option label="金融衍生品类" value="D"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="2.5" style="padding-left: 35px">
                                <el-form-item label="">
                                    <el-checkbox
                                        v-model="specialProducts"
                                        style="margin-left: 20px"
                                        :disabled="disabledAll"
                                        @change="changePtProductType2"
                                        >特殊产品</el-checkbox
                                    >
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="">
                                    <el-select
                                        v-model="indexClause.specialProducts"
                                        @change="changeptProductTypeSelect2"
                                        placeholder="请选择"
                                        multiple
                                        collapse-tags
                                        size="mini"
                                        clearable
                                        :disabled="disabledAll"
                                    >
                                        <el-option label="QDII" value="QDII"></el-option>
                                        <el-option label="FOF" value="FOF"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </template>

            <!-- 系统配置说明 -->
            <template v-if="!['多个复制'].includes(sourceSettteingType)">
                <div style="display: flex; justify-content: space-between">
                    <div style="width: 49%">
                        <div class="card-title">恒生交易系统配置说明</div>
                        <div class="card-content">
                            <el-form ref="form" :model="indexClause" label-width="160px">
                                <el-form-item label="恒生交易系统支持情况:">
                                    <el-select
                                        v-model="indexClause.realTimeSupport"
                                        placeholder="请选择"
                                        size="mini"
                                        :disabled="disabledAll"
                                        clearable
                                    >
                                        <el-option label="支持" value="1"></el-option>
                                        <el-option label="部分支持" value="2"></el-option>
                                        <el-option label="不支持" value="3"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="可配置说明:">
                                    <el-input
                                        type="textarea"
                                        v-model="realTimeSupport.configurableDescription"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width: calc(100% - 15px)"
                                        :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                                <el-form-item label="不可配置说明:">
                                    <el-input
                                        type="textarea"
                                        v-model="realTimeSupport.unconfigurableDescription"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width: calc(100% - 15px)"
                                        :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                                <el-form-item label="注意事项:">
                                    <el-input
                                        type="textarea"
                                        v-model="realTimeSupport.cautions"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width: calc(100% - 15px)"
                                        :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                            </el-form>
                        </div>
                    </div>
                    <div style="width: 49%">
                        <div class="card-title">事后系统配置说明</div>
                        <div class="card-content">
                            <el-form ref="form" :model="indexClause" label-width="160px">
                                <el-form-item label="事后系统支持情况:">
                                    <el-select v-model="indexClause.hdSupport" placeholder="请选择" size="mini" :disabled="disabledAll" clearable>
                                        <el-option label="支持" value="1"></el-option>
                                        <el-option label="部分支持" value="2"></el-option>
                                        <el-option label="不支持" value="3"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="可配置说明:">
                                    <el-input
                                        type="textarea"
                                        v-model="hdSupport.configurableDescription"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width: calc(100% - 15px)"
                                        :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                                <el-form-item label="不可配置说明:">
                                    <el-input
                                        type="textarea"
                                        v-model="hdSupport.unconfigurableDescription"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width: calc(100% - 15px)"
                                        :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                                <el-form-item label="注意事项:">
                                    <el-input
                                        type="textarea"
                                        v-model="hdSupport.cautions"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width: calc(100% - 15px)"
                                        :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                            </el-form>
                        </div>
                    </div>
                </div>
            </template>
            <span slot="footer" class="dialog-footer">
                <el-button @click="handleTreatyArticle('cancel')">取 消</el-button>
                <el-button
                    type="primary"
                    @click="handleTreatyArticle('confirm')"
                    v-if="
                        [
                            '监管类新增',
                            '监管类修改',
                            '单个复制',
                            '合同类新增',
                            '合同类修改',
                            '多个复制',
                            '制度解读类新增',
                            '制度解读类修改',
                            '单个复制制度解读类',
                        ].includes(sourceSettteingType)
                    "
                    >确 定</el-button
                >
            </span>
        </el-dialog>
    </div>
</template>
<script lang="ts">
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import RiskIconButton from '@/common/components/risk-icon-button.vue';
import UploadFileShow from '../commom/upload-file-show.vue';
import { getUser } from '@/utils/user-util';
import { SGU_CACHE } from '@/utils/diction-const-util';
import { downLoadFile } from '@/utils/request';
import { values } from 'xe-utils/methods';
import { dateFormat, timeFormat, getConfigItem } from '@/utils/tools';
import JSEncrypt from 'jsencrypt';
@Component({
    name: 'TreatyArticleDialog',
    components: {
        RiskIconButton,
        UploadFileShow,
    },
})
export default class TreatyArticleDialog extends Vue {
    BASE_URL_API = getConfigItem('BASE_URL_API');
    @Prop() addTreatyDialog; // 新增合规条款弹窗显示
    @Prop() sourceSettteingType; // 条款设置弹窗类型 -- 判断是新增、编辑、查看状态
    @Prop() treeNodeData?; // 当前选择的树节点数据
    @Prop() clauseCodeItem?; // 点击行code
    @Prop() clauseCodes?; // 多选条款
    @Prop() reviewItem?; // 复核行数据
    private dialogVisible: boolean = false;
    private indexSourceCodeSelect = []; // 来源类型select
    private indexSourceCodeSelect1 = []; // 来源名称select
    private VersionNums = [];
    itemProduct = [];
    private title = '';
    private FundTypes: any = []; // 产品类型
    private actionUrl = ''; // 附件上传url
    fundByFundTypeList = []; // 产品信息下拉框
    treatyList = {
        serial: '', // 条款序号
        productInfo: '', // 产品信息
        clauseType: '', // 条款类型
        status: '', // 状态
    };
    fileList1 = [];
    fileList2 = [];
    fileList3 = [];
    fileList4 = [];
    indexClause = {
        articleCode: '',
        productCode: '',
        // 条款基础信息
        clauseCode: '', // 条款基础信息
        directoryCode: '', // 来源类型
        indexSourceName: '', // 来源名称
        clauseStatus: '1', // 是否禁用
        versionNumber: '', // 版本号
        clauseNo: '', // 条款号
        clauseText: '', // 条款原文
        executiveStandArd: '', // 执行标准
        executiveStandArdFileCode: [], // 执行标准文件编码
        depositOpinions: '', // 托管行意见
        depositOpinionsFileCode: [], // 托管行意见文件编码
        industryResearch: '', // 行业调研
        industryResearchFileCode: [], // 行业调研文件编码
        announcements: '', // 注意事项
        announcementsFileCode: [], // 注意事项文件编码
        // 口径引用信息
        outerRuleCaliber: '', // 外规类口径
        projectCaliber: '', // 项目类口径
        // 条款适用产品范围
        passiveTransfinite: '0', // 是否可被动超限
        transfiniteType: '', // 超限调整时间类型
        transfiniteTime: undefined, // 超限调整时间
        publicOffering: false, // 是否公募产品
        suitPublicFundType: '', // 适用产品类型
        excludePublicFundType: '', // 豁免产品类型
        privatePlacement: false, // 是否私募产品
        suitPrivateFundType: '', // 适用私募产品类型
        excludePrivateFundType: '', // 豁免私募产品类型
        cargoBase: false, // 是否货基产品
        suitCargoFundType: '', // 适用货基产品类型
        // 系统配置说明
        realTimeSupport: '', // 恒生交易系统支持情况,
        hdSupport: '', // 事后系统配置说明,
        supportText: '', // 支持情况文本 JSON

        belongFund: '', // 产品信息
        fundType: '', // 产品类型
        indexType: '', // 区分外规类指标、产品类指标
        modifyReason: '', // 修改原因
        originalClauseCode: '',
        pcProductType: [], // 公募产品类型1
        pcProductType2: [], // 公募产品类型2
        ptProductType1: [], // 私募单一
        ptProductType2: [], //
        specialProducts: [], // 特殊产品
        clauseType: '', // 条款类型
        institutionalProvisions: '', // 制度条款
    };
    pcProductType = false; // 公募产品
    ptProductType1 = false; // 私募产品
    specialProducts = false; // 特殊产品
    realTimeSupport = {
        // 恒生交易系统配置说明
        configurableDescription: '',
        unconfigurableDescription: '',
        cautions: '',
    };
    hdSupport = {
        // 事后系统配置说明
        configurableDescription: '',
        unconfigurableDescription: '',
        cautions: '',
    };
    headerObj = {
        Authentication: getUser().sessionId,
    };
    disabledAll = false;
    removal = {
        directoryCode: '', // 迁移来源类型
        indexSourceName: '', // 迁移来源名称
        articleDeatilsCode: '',
    };
    rsaPassWord: any = null; // 加密
    private moveIndexArticleCodeList = []; // 迁移版本号select

    created() {
        // const baseUrl = process.env.ENV_CONFIG === 'project' ? window.project_config.baseUrlApi : process.env.BASE_URL_API;
        // this.actionUrl = baseUrl + '/system/upload/1';
        this.actionUrl = this.BASE_URL_API + '/apiAssetFile/upload';
    }
    @Watch('addTreatyDialog')
    async handleAddTreatyDialog(val) {
        this.dialogVisible = val;
        if (val == true) {
            this.title = '合规条款' + this.sourceSettteingType.slice(this.sourceSettteingType.length - 2, this.sourceSettteingType.length);
            this.FundTypes = await SGU_CACHE('FundType', '/dict/list/code/Y_000002', []);
            var encryptor = new JSEncrypt(); // 创建加密对象实例
            // 之前ssl生成的公钥，复制的时候要小心不要有空格
            var pubKey =
                'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI1/pR72vGeQoQ8YxKVrDzV6RriOkNkW0UWw4JgXhH417lULhKMQWK3GeJW+Tg0kHlhpx4iQNxrEPlroCqZfylgPI+x0AohcnvkY52VGQGLnms2tMefBKdz2BHUAp7MdF7GsGtpiHWSZbEWk5onkB7pH8Q0KlNAB+7BoNTj9MOywIDAQAB';
            encryptor.setPublicKey(pubKey); // 设置公钥
            this.rsaPassWord = encryptor.encrypt('zszg@zgssfkxt'); // 对内容进行加密
            // 查看状态禁止修改
            if (['监管类查看', '合同类查看', '制度解读类查看'].includes(this.sourceSettteingType)) {
                this.disabledAll = true;
            }
            // 来源类型、来源名称
            if (!['单个复制', '多个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)) {
                this.getIndexSourceSelect1('');
            }

            console.log('dialog子组件:this.sourceSettteingType', this.sourceSettteingType);

            if (['监管类新增', '制度解读类新增'].includes(this.sourceSettteingType)) {
                this.getVersionNums(this.treeNodeData.id);
                this.getIndexSourceSelect();
                this.getIndexSourceSelect1('');
                this.indexClause.directoryCode = this.treeNodeData.parentCode;
                this.indexClause.indexSourceName = this.treeNodeData.id;
                this.indexClause.articleCode = this.treeNodeData.id;
                this.indexClause.indexType = this.treeNodeData.indexType;
            } else if (['监管类修改', '监管类查看', '制度解读类修改', '制度解读类查看'].includes(this.sourceSettteingType)) {
                this.getIndexSourceSelect();
                this.getIndexSourceSelect1('');
                // this.getVersionNums(this.treeNodeData.id);
                this.getVersionNums(this.clauseCodeItem.articleCode);
                this.getDetailData(this.clauseCodeItem.clauseCode);
            } else if (['合同类新增'].includes(this.sourceSettteingType)) {
                this.getVersionNums(this.treeNodeData.id);
                this.getProduct();
                this.indexClause.indexType = '2';
                this.indexClause.directoryCode = this.treeNodeData.productTypes;
                this.indexClause.articleCode = this.treeNodeData.id;
                this.indexClause.productCode = this.treeNodeData.productCode;
            } else if (['合同类修改', '合同类查看'].includes(this.sourceSettteingType)) {
                this.getVersionNums(this.clauseCodeItem.articleCode);
                this.getProduct();
                // this.getFundByFundType(this.treeNodeData.belongFund)
                this.indexClause.belongFund = this.treeNodeData.id;
                this.indexClause.articleCode = this.treeNodeData.id;
                this.indexClause.productCode = this.treeNodeData.productCode;
                this.getDetailData(this.clauseCodeItem.clauseCode);
            } else if (['单个复制', '多个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)) {
                this.getIndexSourceSelect();
                if (['单个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)) {
                    this.getVersionNums(this.treeNodeData.id);
                    this.getDetailData(this.clauseCodes[0]);
                }
            }

            this.getIndexSourceSelect1(this.treeNodeData.indexType);
        } else if (val == false) {
            this.indexClause = {
                articleCode: '',
                productCode: '',
                // 条款基础信息
                clauseCode: '', // 条款基础信息
                directoryCode: '', // 来源类型
                indexSourceName: '', // 来源名称
                clauseStatus: '1', // 是否禁用
                versionNumber: '', // 版本号
                clauseNo: '', // 条款号
                clauseText: '', // 条款原文
                executiveStandArd: '', // 执行标准
                executiveStandArdFileCode: [], // 执行标准文件编码
                depositOpinions: '', // 托管行意见
                depositOpinionsFileCode: [], // 托管行意见文件编码
                industryResearch: '', // 行业调研
                industryResearchFileCode: [], // 行业调研文件编码
                announcements: '', // 注意事项
                announcementsFileCode: [], // 注意事项文件编码
                // 口径引用信息
                outerRuleCaliber: '', // 外规类口径
                projectCaliber: '', // 项目类口径
                // 条款适用产品范围
                passiveTransfinite: '0', // 是否可被动超限
                transfiniteType: '', // 超限调整时间
                transfiniteTime: undefined, // 超限调整时间
                publicOffering: false, // 是否公募产品
                suitPublicFundType: '', // 适用产品类型
                excludePublicFundType: '', // 豁免产品类型
                privatePlacement: false, // 是否私募产品
                suitPrivateFundType: '', // 适用私募产品类型
                excludePrivateFundType: '', // 豁免私募产品类型
                cargoBase: false, // 是否货基产品
                suitCargoFundType: '', // 适用货基产品类型
                // 系统配置说明
                realTimeSupport: '', // 恒生交易系统支持情况,
                hdSupport: '', // 事后系统配置说明,
                supportText: '', // 支持情况文本 JSON
                belongFund: '', // 产品信息
                fundType: '', // 产品类型
                indexType: '', // 区分外规类指标、产品类指标
                modifyReason: '', // 修改原因
                originalClauseCode: '',
                pcProductType: [], // 公募产品-类型1
                pcProductType2: [], // 公募产品类型2
                ptProductType1: [], // 私募单一
                ptProductType2: [], //
                specialProducts: [], // 特殊产品
                clauseType: '', // 条款类型
                institutionalProvisions: '', // 制度条款
            };
            this.realTimeSupport = {
                // 恒生交易系统配置说明
                configurableDescription: '',
                unconfigurableDescription: '',
                cautions: '',
            };
            this.hdSupport = {
                // 事后系统配置说明
                configurableDescription: '',
                unconfigurableDescription: '',
                cautions: '',
            };
            this.removal = {
                directoryCode: '',
                indexSourceName: '',
                articleDeatilsCode: '',
            };
            this.fileList1 = [];
            this.fileList2 = [];
            this.fileList3 = [];
            this.fileList4 = [];
            this.disabledAll = false;
            this.indexSourceCodeSelect = [];
            this.indexSourceCodeSelect1 = [];
            this.pcProductType = false; // 公募产品
            this.ptProductType1 = false; // 私募产品
            this.specialProducts = false; // 特殊产品
            this.moveIndexArticleCodeList = [];
        }
    }
    @Watch('dialogVisible')
    handleDialogVisible(val) {
        this.$emit('emitTreatyArticle', val, '');
    }
    @Watch('addTreatyDialog')
    handleAddSourceDialog(val) {
        this.dialogVisible = val;
    }

    // 迁移版本号
    getMoveVersionNums(indexCode) {
        this.$axios.post('/zhiguan/indexArticle/articleDetails/query', { articleCode: indexCode }).then((res: any) => {
            if (res) {
                this.moveIndexArticleCodeList = [];
                res.forEach(item => this.moveIndexArticleCodeList.push(item));
            }
        });
    }

    // 迁移条文选择
    changeMovedIndexSource(param) {
        if (param) {
            this.getMoveVersionNums(param);
        } else {
            this.moveIndexArticleCodeList = [];
        }
        this.removal.articleDeatilsCode = '';
    }

    // 编辑
    getDetailData(data) {
        this.$axios.post('/zhiguan/indexClause/getClauseDetails', { clauseCode: data }).then((res: any) => {
            if (res) {
                this.fileList1 = [];
                this.fileList2 = [];
                this.fileList3 = [];
                this.fileList4 = [];
                this.indexClause = { ...res };
                // if (['监管类修改', '单个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)) {
                //     this.indexClause.indexType = '1';
                // } else if (this.sourceSettteingType == '合同类修改') {
                //     this.indexClause.indexType = '2';
                // }
                if (res.supportText) {
                    let supportText = JSON.parse(res.supportText);
                    this.realTimeSupport = { ...supportText[0] };
                    this.hdSupport = { ...supportText[1] };
                }
                if (res.ptProductType1) {
                    this.indexClause.ptProductType1 = [];
                    this.indexClause.ptProductType2 = [];
                    res.ptProductType1.forEach(item => {
                        if (['A2', 'B1'].includes(item)) {
                            this.indexClause.ptProductType1.push(item);
                        }
                        if (['A', 'B', 'C', 'D'].includes(item)) {
                            this.indexClause.ptProductType2.push(item);
                        }
                    });
                }
                if (res.executiveStandardFiles) {
                    res.executiveStandardFiles.forEach(item => {
                        this.fileList1.push({ name: item.fileName, fileNo: item.fileId });
                    });
                }
                if (res.depositOpinionsFiles) {
                    res.depositOpinionsFiles.forEach(item => {
                        this.fileList2.push({ name: item.fileName, fileNo: item.fileId });
                    });
                }
                if (res.industryResearchFiles) {
                    res.industryResearchFiles.forEach(item => {
                        this.fileList3.push({ name: item.fileName, fileNo: item.fileId });
                    });
                }
                if (res.announcementsFiles) {
                    res.announcementsFiles.forEach(item => {
                        this.fileList4.push({ name: item.fileName, fileNo: item.fileId });
                    });
                }
            }
        });
    }
    // 获取条款序号
    getClauseCode() {
        this.$axios.get('/indexClause/getClauseCode').then((res: any) => {
            this.indexClause.clauseCode = res;
        });
    }
    // 根据产品类型获取产品
    getFundByFundType(dictKey) {
        this.$axios
            .post('/indexClause/getFundByFundType', {
                dictKey: dictKey,
            })
            .then((res: any) => {
                this.fundByFundTypeList = [];
                if (res) {
                    res.forEach(item => this.fundByFundTypeList.push(item));
                }
            });
    }
    // 迁移来源类型change
    changeSourceType(value) {
        this.getIndexSourceSelect1(value);

        this.moveIndexArticleCodeList = [];
        this.removal.articleDeatilsCode = '';
        this.removal.indexSourceName = '';
    }
    // 是否可被动超限
    changePassiveTransfinite(param) {
        if (param == '0') {
            this.indexClause.transfiniteType = '';
            this.indexClause.transfiniteTime = undefined;
        }
    }
    changePcProductTypeSelect(param) {
        if (param.length == 4 && this.indexClause.pcProductType2.length == 2) {
            this.pcProductType = true;
        } else {
            this.pcProductType = false;
        }
    }
    changePcProductTypeSelect2(param) {
        if (param.length == 2 && this.indexClause.pcProductType.length == 4) {
            this.pcProductType = true;
        } else {
            this.pcProductType = false;
        }
    }
    // 公募产品
    changePcProductType(param) {
        if (param == false) {
            this.indexClause.pcProductType = [];
            this.indexClause.pcProductType2 = [];
        } else if (param == true) {
            this.indexClause.pcProductType = ['1', '2', '3', '4'];
            this.indexClause.pcProductType2 = ['1', '2'];
        }
    }
    // 私募产品
    changePtProductType1(param) {
        if (param == false) {
            this.indexClause.ptProductType1 = [];
            this.indexClause.ptProductType2 = [];
        } else if (param == true) {
            this.indexClause.ptProductType1 = ['A2', 'B1'];
            this.indexClause.ptProductType2 = ['A', 'B', 'C', 'D'];
        }
    }
    // 特殊产品
    changePtProductType2(param) {
        if (param == false) {
            this.indexClause.specialProducts = [];
        } else if (param == true) {
            this.indexClause.specialProducts = ['QDII', 'FOF'];
        }
    }
    changeptProductTypeSelect(param) {
        if (param.length == 2 && this.indexClause.ptProductType2.length == 4) {
            this.ptProductType1 = true;
        } else {
            this.ptProductType1 = false;
        }
    }
    changeptptProductType2Select(param) {
        if (param.length == 4 && this.indexClause.ptProductType1.length == 2) {
            this.ptProductType1 = true;
        } else {
            this.ptProductType1 = false;
        }
    }
    changeptProductTypeSelect2(param) {
        if (param.length == 2) {
            this.specialProducts = true;
        } else {
            this.specialProducts = false;
        }
    }
    // 条目来源分类下拉-三级
    getIndexSourceSelect() {
        if (this.treeNodeData.indexType != '2') {
            this.$axios.post('/zhiguan/indexArticle/directory/query', { parentCode: '' }).then((res: any) => {
                if (res) {
                    this.indexSourceCodeSelect = [];
                    if (this.treeNodeData.indexType == '1') {
                        res.forEach(item => {
                            if (item.indexType == '1') {
                                this.indexSourceCodeSelect.push(item);
                            }
                        });
                    } else if (this.treeNodeData.indexType == '3') {
                        res.forEach(item => {
                            if (item.indexType == '3') {
                                this.indexSourceCodeSelect.push(item);
                            }
                        });
                    }
                }
            });
        } else if (this.treeNodeData.indexType == '2') {
            this.$axios.post('/zhiguan/indexArticle/directory/product/query', { parentCode: '' }).then((res: any) => {
                if (res) {
                    this.indexSourceCodeSelect = [];
                    res.forEach(item => this.indexSourceCodeSelect.push(item));
                }
            });
        }
    }
    // 产品信息
    getProduct() {
        this.$axios.post('/zhiguan/indexArticle/directory/product/query', { parentCode: '', indexType: '2' }).then((res: any) => {
            if (res) {
                this.itemProduct = [];
                res.forEach(item => this.itemProduct.push(item));
            }
        });
    }
    // 来源名称下拉
    getIndexSourceSelect1(data) {
        if (!(this.treeNodeData.indexType == '2')) {
            this.$axios.post('/zhiguan/indexArticle/article/query', { indexDirectoryCode: data }).then((res: any) => {
                this.indexSourceCodeSelect1 = [];
                res.forEach(item => this.indexSourceCodeSelect1.push(item));
            });
        } else {
            this.indexSourceCodeSelect = [];
            this.indexSourceCodeSelect = [
                {
                    indexDirectoryCode: '5',
                    indexName: '公募',
                    level: '3',
                    indexType: '2',
                    children: [],
                },
                {
                    indexDirectoryCode: '6',
                    indexName: '私募单一',
                    level: '3',
                    indexType: '2',
                    children: [],
                },
                {
                    indexDirectoryCode: '7',
                    indexName: '私募集合',
                    level: '3',
                    indexType: '2',
                    children: [],
                },
                {
                    indexDirectoryCode: '8',
                    indexName: '公募',
                    level: '3',
                    indexType: '2',
                    children: [],
                },
                {
                    indexDirectoryCode: '9',
                    indexName: '私募单一',
                    level: '3',
                    indexType: '2',
                    children: [],
                },
                {
                    indexDirectoryCode: '10',
                    indexName: '私募集合',
                    level: '3',
                    indexType: '2',
                    children: [],
                },
            ];
        }
    }
    // 获取当前来源的所有版本号
    getVersionNums(indexCode) {
        this.$axios
            .post('/zhiguan/indexArticle/articleDetails/query', {
                articleCode: indexCode,
            })
            .then((res: any) => {
                this.VersionNums = [];
                res.forEach(item => this.VersionNums.push(item));
            });
    }
    handleTreatyArticle(parameter) {
        if (parameter == 'cancel') {
            this.$emit('emitTreatyArticle', false, '');
        } else if (parameter == 'confirm') {
            if (
                this.indexClause.directoryCode == '' &&
                ['监管类新增', '监管类修改', '监管类查看', '单个复制', '制度解读类新增', '制度解读类修改', '单个复制制度解读类'].includes(
                    this.sourceSettteingType
                )
            ) {
                this.yh_message_warn('来源类型不可为空!');
                return;
            }
            if (
                this.indexClause.indexSourceName == '' &&
                ['监管类新增', '监管类修改', '监管类查看', '单个复制', '制度解读类新增', '制度解读类修改', '单个复制制度解读类'].includes(
                    this.sourceSettteingType
                )
            ) {
                this.yh_message_warn('来源名称不可为空!');
                return;
            }
            if (this.indexClause.directoryCode == '' && ['合同类新增', '合同类修改', '合同类查看'].includes(this.sourceSettteingType)) {
                this.yh_message_warn('产品类型不可为空!');
                return;
            }
            if (this.indexClause.articleCode == '' && ['合同类新增', '合同类修改', '合同类查看'].includes(this.sourceSettteingType)) {
                this.yh_message_warn('产品信息不可为空!');
                return;
            }
            if (this.indexClause.versionNumber == '' && !['合同类新增', '合同类修改', '多个复制'].includes(this.sourceSettteingType)) {
                this.yh_message_warn('版本号不可为空!');
                return;
            }
            if (this.indexClause.versionNumber == '' && ['合同类新增', '合同类修改'].includes(this.sourceSettteingType)) {
                this.yh_message_warn('合同名称不可为空!');
                return;
            }
            if (this.indexClause.clauseType == '' && ['合同类新增', '合同类修改', '合同类查看'].includes(this.sourceSettteingType)) {
                this.yh_message_warn('条款类型不可为空!');
                return;
            }
            // if (
            //     this.indexClause.clauseNo == '' &&
            //     [
            //         '监管类新增',
            //         '监管类修改',
            //         '监管类查看',
            //         '单个复制',
            //         '合同类新增',
            //         '合同类修改',
            //         '合同类查看',
            //         '制度解读类新增',
            //         '制度解读类修改',
            //         '制度解读类查看',
            //         '单个复制制度解读类',
            //     ].includes(this.sourceSettteingType)
            // ) {
            //     this.yh_message_warn('条款号不可为空!');
            //     return;
            // }
            if (
                this.indexClause.clauseText == '' &&
                !['制度解读类新增', '制度解读类修改', '多个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)
            ) {
                this.yh_message_warn('条款原文不可为空!');
                return;
            }
            if (
                this.indexClause.institutionalProvisions == '' &&
                ['制度解读类新增', '制度解读类修改', '单个复制制度解读类'].includes(this.sourceSettteingType)
            ) {
                this.yh_message_warn('制度条款不可为空!');
                return;
            }
            if (
                this.indexClause.executiveStandArd == '' &&
                ['制度解读类新增', '制度解读类修改', '单个复制制度解读类'].includes(this.sourceSettteingType)
            ) {
                this.yh_message_warn('条款解读不可为空!');
                return;
            }
            if (
                this.indexClause.executiveStandArd == '' &&
                !['制度解读类新增', '制度解读类修改', '多个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)
            ) {
                this.yh_message_warn('执行标准不可为空!');
                return;
            }

            if (this.indexClause.passiveTransfinite == '1' && !this.indexClause.transfiniteType && this.sourceSettteingType != '多个复制') {
                this.yh_message_warn('超限调整时间不可为空!');
                return;
            }
            if (
                [
                    '监管类新增',
                    '监管类修改',
                    '监管类查看',
                    '单个复制',
                    '制度解读类新增',
                    '制度解读类修改',
                    '制度解读类查看',
                    '单个复制制度解读类',
                ].includes(this.sourceSettteingType)
            ) {
                if (
                    this.indexClause.pcProductType.length == 0 &&
                    this.indexClause.pcProductType2.length == 0 &&
                    this.indexClause.ptProductType1.length == 0 &&
                    this.indexClause.ptProductType2.length == 0 &&
                    this.indexClause.specialProducts.length == 0
                ) {
                    this.yh_message_warn('条款适用产品范围不可为空!');
                    return;
                }
            }
            if (['单个复制', '多个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)) {
                if (this.removal.directoryCode == '') {
                    this.yh_message_warn('迁移来源类型不可为空！');
                    return;
                }
                if (this.removal.indexSourceName == '') {
                    this.yh_message_warn('迁移来源名称不可为空！');
                    return;
                }
                if (this.removal.articleDeatilsCode == '') {
                    this.yh_message_warn('迁移来源版本号不可为空！');
                    return;
                }
                if (['单个复制', '单个复制制度解读类'].includes(this.sourceSettteingType)) {
                    let jsonText = [];
                    jsonText.push(this.realTimeSupport);
                    jsonText.push(this.hdSupport);
                    this.indexClause.supportText = JSON.stringify(jsonText || []);
                    this.indexClause.executiveStandArdFileCode = [];
                    this.indexClause.depositOpinionsFileCode = [];
                    this.indexClause.industryResearchFileCode = [];
                    this.indexClause.announcementsFileCode = [];
                    this.fileList1.forEach(item => this.indexClause.executiveStandArdFileCode.push(item.fileNo));
                    this.fileList2.forEach(item => this.indexClause.depositOpinionsFileCode.push(item.fileNo));
                    this.fileList3.forEach(item => this.indexClause.industryResearchFileCode.push(item.fileNo));
                    this.fileList4.forEach(item => this.indexClause.announcementsFileCode.push(item.fileNo));
                    this.indexClause.directoryCode = this.removal.directoryCode;
                    this.indexClause.indexSourceName = this.removal.indexSourceName;
                    this.indexClause.articleCode = this.removal.indexSourceName;
                    this.indexClause.originalClauseCode = this.clauseCodes[0];
                    if (this.indexClause.passiveTransfinite == '0') {
                        this.indexClause.transfiniteType = '';
                        this.indexClause.transfiniteTime = undefined;
                    }
                    let indexClause = { ...this.indexClause };
                    indexClause.ptProductType1 = [];
                    indexClause.ptProductType2 = [];
                    this.indexClause.ptProductType1.forEach(item => {
                        indexClause.ptProductType1.push(item);
                    });
                    this.indexClause.ptProductType2.forEach(item => {
                        indexClause.ptProductType1.push(item);
                    });

                    this.$axios
                        .post('/zhiguan/indexClause/multipleCopy', {
                            indexClausePO: indexClause,
                            articleCode: this.removal.indexSourceName,
                            directoryCode: this.removal.directoryCode,
                            articleDeatilsCode: this.removal.articleDeatilsCode,
                        })
                        .then((res: any) => {
                            this.yh_message_success(this.sourceSettteingType + '成功');
                            this.$emit('emitTreatyArticle', false, 'query');
                        });
                } else if (this.sourceSettteingType == '多个复制') {
                    this.$axios
                        .post('/zhiguan/indexClause/multipleCopy', {
                            directoryCode: this.removal.directoryCode,
                            indexSourceName: this.removal.indexSourceName,
                            articleCode: this.removal.indexSourceName,
                            articleDeatilsCode: this.removal.articleDeatilsCode,
                            clauseList: this.clauseCodes,
                        })
                        .then((res: any) => {
                            this.yh_message_success('迁移复制成功！');
                            this.dialogVisible = false;
                            this.$emit('emitTreatyArticle', false, 'query');
                        });
                }
            } else if (
                ['监管类新增', '合同类新增', '监管类修改', '合同类修改', '制度解读类新增', '制度解读类修改', '单个复制制度解读类'].includes(
                    this.sourceSettteingType
                )
            ) {
                let jsonText = [];
                jsonText.push(this.realTimeSupport);
                jsonText.push(this.hdSupport);
                this.indexClause.supportText = JSON.stringify(jsonText || []);
                this.indexClause.executiveStandArdFileCode = [];
                this.indexClause.depositOpinionsFileCode = [];
                this.indexClause.industryResearchFileCode = [];
                this.indexClause.announcementsFileCode = [];
                this.fileList1.forEach(item => this.indexClause.executiveStandArdFileCode.push(item.fileNo));
                this.fileList2.forEach(item => this.indexClause.depositOpinionsFileCode.push(item.fileNo));
                this.fileList3.forEach(item => this.indexClause.industryResearchFileCode.push(item.fileNo));
                this.fileList4.forEach(item => this.indexClause.announcementsFileCode.push(item.fileNo));
                if (this.indexClause.passiveTransfinite == '0') {
                    this.indexClause.transfiniteType = '';
                    this.indexClause.transfiniteTime = undefined;
                }
                let indexClause = { ...this.indexClause };
                indexClause.ptProductType1 = [];
                indexClause.ptProductType2 = [];
                this.indexClause.ptProductType1.forEach(item => {
                    indexClause.ptProductType1.push(item);
                });
                this.indexClause.ptProductType2.forEach(item => {
                    indexClause.ptProductType1.push(item);
                });

                // return
                if (['监管类新增', '合同类新增', '制度解读类新增'].includes(this.sourceSettteingType)) {
                    this.$axios.post('/zhiguan/indexClause/add', indexClause).then((res: any) => {
                        this.yh_message_success('新增成功');
                        this.$emit('emitTreatyArticle', false, 'query');
                    });
                } else if (['监管类修改', '合同类修改', '制度解读类修改', '单个复制制度解读类'].includes(this.sourceSettteingType)) {
                    this.$axios
                        .post('/zhiguan/indexClause/update', indexClause)
                        .then((res: any) => {
                            this.yh_message_success('修改成功');
                            this.$emit('emitTreatyArticle', false, 'query');
                        })
                        .catch(() => {
                            this.$emit('emitTreatyArticle', true, 'query');
                        });
                }
            }
        }
    }
    // 文件上传
    uploadFileSuccess(res, file, fileList, type) {
        console.log('uploadFileSuccess', res);
        if (res.returnMsg && res.returnMsg !== 'SUCCESS') {
            this.$message.warning(res.returnMsg);
            return;
        }
        if (type == '执行标准') {
            this.fileList1.push({
                name: res.data.fileName,
                // url: res.data.relativePath,
                fileNo: res.data.fileId,
            });
        } else if (type == '托管行意见') {
            this.fileList2.push({
                name: res.data.fileName,
                // url: res.data.relativePath,
                fileNo: res.data.fileId,
            });
        } else if (type == '行业调研') {
            this.fileList3.push({
                name: res.data.fileName,
                // url: res.data.relativePath,
                fileNo: res.data.fileId,
            });
        } else if (type == '注意事项') {
            this.fileList4.push({
                name: res.data.fileName,
                // url: res.data.relativePath,
                fileNo: res.data.fileId,
            });
        }
    }
    uploadFileError(res, file, fileList, type) {
        this.$message.warning('文件格式不支持!');
    }
    // 下载文件
    downLoadFileBtn(param) {
        // downLoadFile({
        //     url: '/apiAssetFile/downLoad' + param.fileNo,
        //     method: 'get',
        // });
        downLoadFile({
            url: '/apiAssetFile/downLoad',
            method: 'post',
            data: { fileId: [param.fileNo], fileName: param.name, passWord: this.rsaPassWord },
        });
    }
    // 删除已上传文件
    confirmDelFile1(param) {
        this.fileList1.forEach((item, index) => {
            if (item.fileNo == param.fileNo) {
                this.fileList1.splice(index, 1);
            }
        });
    }
    confirmDelFile2(param) {
        this.fileList2.forEach((item, index) => {
            if (item.fileNo == param.fileNo) {
                this.fileList2.splice(index, 1);
            }
        });
    }
    confirmDelFile3(param) {
        this.fileList3.forEach((item, index) => {
            if (item.fileNo == param.fileNo) {
                this.fileList3.splice(index, 1);
            }
        });
    }
    confirmDelFile4(param) {
        this.fileList4.forEach((item, index) => {
            if (item.fileNo == param.fileNo) {
                this.fileList4.splice(index, 1);
            }
        });
    }
    blurDay(value) {
        this.indexClause.transfiniteTime = this.indexClause.transfiniteTime.replace(/^(0+)|[^\d]+/g, '');
        return this.indexClause.transfiniteTime;
    }

    /**
     * 跳转 账户组设置
     */
    goToFundGroup() {
        const msg = {
            type: 'fund-group-setting',
            path: '/risk/baseparam/fundGroupSetting',
            title: '账户组设置',
        };
        top.window.postMessage(msg, '*');
    }
}
</script>
<style lang="scss" scoped>
.treaty-title {
    height: 25px;
    line-height: 20px;
    margin-top: -10px;
}
.card-title {
    color: red;
    height: 25px;
    line-height: 25px;
    margin: 15px 0px 2px 0;
}
.card-content {
    width: 100%;
    border: 2px solid rgba(174, 174, 174, 0.5);
    padding-top: 10px;
}
/deep/ .el-dialog {
    overflow: auto;
}
.uploadBtn:hover {
    background: #f5f7fa;
}
.fileName:hover {
    text-decoration: underline;
    color: #48a2ff;
}

.fdg-row {
    position: relative;

    .fdg-btn {
        position: absolute;
        bottom: -38px;
        right: 0;
    }
}

/deep/ .textarea-width {
    width: 100%;

    .el-form-item__content {
        width: calc(100% - 120px);
    }
}
</style>
